package com.kbtx.st0601;

import java.util.List;

public class KLV {
    // All KLVs tags from the MISB0601
    public static int CHECKSUM = 1;
    public static int UNIX_TIME_STAMP = 2;
    public static int MISSION_ID = 3;
    public static int PLATFORM_TAIL_NUMBER = 4;
    public static int PLATFORM_HEADING_ANGLE = 5;
    public static int PLATFORM_PITCH_ANGLE = 6;
    public static int PLATFORM_ROLL_ANGLE = 7;
    public static int PLATFORM_TRUE_AIRSPEED = 8;
    public static int PLATFORM_INDICATED_AIRSPEED = 9;
    public static int PLATFORM_DESIGNATION = 10;
    public static int IMAGE_SOURCE_SENSOR = 11;
    public static int IMAGE_COORDINATE_SYSTEM = 12;
    public static int SENSOR_LATITUDE = 13;
    public static int SENSOR_LONGITUDE = 14;
    public static int SENSOR_TRUE_ALTITUDE = 15;
    public static int SENSOR_HORIZONTAL_FOV = 16;
    public static int SENSOR_VERTICAL_FOV = 17;
    public static int SENSOR_RELATIVE_AZIMUTH_ANGLE = 18;
    public static int SENSOR_RELATIVE_ELEVATION_ANGLE = 19;
    public static int SENSOR_RELATIVE_ROLL_ANGLE = 20;
    public static int SLANT_RANGE = 21;
    public static int TARGET_WIDTH = 22;
    public static int FRAME_CENTER_LATITUDE = 23;
    public static int FRAME_CENTER_LONGITUDE = 24;
    public static int FRAME_CENTER_ELEVATION = 25;
    public static int OFFSET_CORNER_LATITUDE_POINT_1 = 26;
    public static int OFFSET_CORNER_LONGITUDE_POINT_1 = 27;
    public static int OFFSET_CORNER_LATITUDE_POINT_2 = 28;
    public static int OFFSET_CORNER_LONGITUDE_POINT_2 = 29;
    public static int OFFSET_CORNER_LATITUDE_POINT_3 = 30;
    public static int OFFSET_CORNER_LONGITUDE_POINT_3 = 31;
    public static int OFFSET_CORNER_LATITUDE_POINT_4 = 32;
    public static int OFFSET_CORNER_LONGITUDE_POINT_4 = 33;
    public static int ICING_DETECTED = 34;
    public static int WIND_DIRECTION = 35;
    public static int WIND_SPEED = 36;
    public static int STATIC_PRESSURE = 37;
    public static int DENSITY_ALTITUDE = 38;
    public static int OUTSIDE_AIR_TEMPERATURE = 39;
    public static int TARGET_LOCATION_LATITUDE = 40;
    public static int TARGET_LOCATION_LONGITUDE = 41;
    public static int TARGET_LOCATION_ELEVATION = 42;
    public static int TARGET_TRACK_GATE_WIDTH = 43;
    public static int TARGET_TRACK_GATE_HEIGHT = 44;
    public static int TARGET_ERROR_ESTIMATE_CE90 = 45;
    public static int TARGET_ERROR_ESTIMATE_LE90 = 46;
    public static int GENERIC_FLAG_DATA1 = 47;
    public static int SECURITY_LOCAL_METADATA_SET = 48;
    public static int DIFFERENTIAL_PRESSURE = 49;
    public static int PLATFORM_ANGLE_OF_ATTACK = 50;
    public static int PLATFORM_VERTICAL_SPEED = 51;
    public static int PLATFORM_SIDESLIP_ANGLE = 52;
    public static int AIRFIELD_BAROMETRIC_PRESSURE = 53;
    public static int AIRFIELD_ELEVATION = 54;
    public static int RELATIVE_HUMIDITY = 55;
    public static int PLATFORM_GROUND_SPEED = 56;
    public static int GROUND_RANGE = 57;
    public static int PLATFORM_FUEL_REMAINING = 58;
    public static int PLATFORM_CALL_SIGN = 59;
    public static int WEAPON_LOAD = 60;
    public static int WEAPON_FIRED = 61;
    public static int LASER_PRF_CODE = 62;
    public static int SENSOR_FOV_NAME = 63;
    public static int PLATFORM_MAGNETIC_HEADING = 64;
    public static int UAS_LDS_VERSION_NUMBER = 65;
    public static int TARGET_LOCATION_COVARIANCE_MATRIX = 66;
    public static int ALTERNATE_PLATFORM_LATITUDE = 67;
    public static int ALTERNATE_PLATFORM_LONGITUDE = 68;
    public static int ALTERNATE_PLATFORM_ALTITUDE = 69;
    public static int ALTERNATE_PLATFORM_NAME = 70;
    public static int ALTERNATE_PLATFORM_HEADING = 71;
    public static int EVENT_START_TIME_UTC = 72;
    public static int RVT_LOCAL_DATA_SET = 73;
    public static int VMTI_LOCAL_DATA_SET = 74;
    public static int SENSOR_ELLIPSOID_HEIGHT = 75;
    public static int ALTERNATE_PLATFORM_ELLIPSOID_HEIGHT = 76;
    public static int OPERATIONAL_MODE = 77;
    public static int FRAME_CENTER_HEIGHT_ABOVE_ELLIPSOID = 78;
    public static int SENSOR_NORTH_VELOCITY = 79;
    public static int SENSOR_EAST_VELOCITY = 80;
    public static int IMAGE_HORIZON_PIXEL_PACK = 81;
    public static int CORNER_LATITUDE_POINT_1 = 82;
    public static int CORNER_LONGITUDE_POINT_1 = 83;
    public static int CORNER_LATITUDE_POINT_2 = 84;
    public static int CORNER_LONGITUDE_POINT_2 = 85;
    public static int CORNER_LATITUDE_POINT_3 = 86;
    public static int CORNER_LONGITUDE_POINT_3 = 87;
    public static int CORNER_LATITUDE_POINT_4 = 88;
    public static int CORNER_LONGITUDE_POINT_4 = 89;
    public static int PLATFORM_PITCH_ANGLE_F = 90;
    public static int PLATFORM_ROLL_ANGLE_F = 91;
    public static int PLATFORM_ANGLE_OF_ATTACK_F = 92;
    public static int PLATFORM_SIDESLIP_ANGLE_F = 93;

    private final int tag;
    private final int size;
    private final Object value;

    public KLV(int tag, int size, Object value) {
        this.tag = tag;
        this.size = size;
        this.value = value;
    }

    public int getTag() {
        return tag;
    }

    public int getSize() {
        return size;
    }

    public Object getValue() {
        return value;
    }

    @Override
    public String toString() {
        return "KLV{" +
                "tag=" + tag +
                ", size=" + size +
                ", value=" + value +
                '}';
    }


    public static List<KLV> unpackMisb(byte[] data) {
        return unpackMisb(data, data.length);
    }
    private static native List<KLV> unpackMisb(byte[] data, int length);

    //    private native void packMisb();
    private static native byte[] packMisb();
}
